#include "PreprocessedDataLoader.h"
#include "PreprocessedFile.h"

#include <qfiledialog.h>
#include <qstringlist.h>
#include <qstring.h>

PreprocessedDataLoader::PreprocessedDataLoader()
{
}

void PreprocessedDataLoader::load()
{
    QFileDialog dialog(NULL);

    dialog.setAcceptMode(QFileDialog::AcceptOpen);
    dialog.setNameFilter("Preprocessed Object Point files (*.pop)");
    dialog.setViewMode(QFileDialog::List);
    dialog.setFileMode(QFileDialog::ExistingFile);

    if (dialog.exec())
    {
        if ( dialog.selectedFiles().size() == 1 )
        {
            QStringList list = dialog.selectedFiles();
            QString targetFile = list[0];

            // showing the initial setup dialog!

            PreprocessedFile file;
            file.load(targetFile);

            m_cameras = file.getCameras();
            m_point_cloud = file.getPointCloud();
        }
        else
        {
            // show error // no need for now
        }
    }
}
